#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__ = 'gtlions'
import psycopg2, csv

# dbgp = psycopg2.connect(dbname = "gtlions", user = "gpadmin", password = "000000", host = "192.168.100.60")
dbgp = psycopg2.connect(dbname="gtlions", user="postgres", password="000000", host="localhost")
f = open("gp.csv", "w")
writer = csv.writer(f, lineterminator="\n", quoting=csv.QUOTE_NONNUMERIC)
cursor = dbgp.cursor()
cursor.execute("select * from test limit 2")
for row in cursor:
    print row
    writer.writerow(row)
f.close()

# reader = csv.reader(open("gp.csv","r"))
# lines = []
# for line in reader:
#     lines.append(line)
#
# print lines
